﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>选择联络员</title>
    <link href="../Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" />
    <link href="../Scripts/bootstrap/css/components-rounded.css" rel="stylesheet" />
    <link href="../Scripts/bootstrap/css/font-awesome.css" rel="stylesheet" />
    <link href="../Scripts/bootstrap/css/themes/default/style.min.css" rel="stylesheet" />
    <link href="../Scripts/easyUI145/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../Scripts/layui/layui/css/modules/layer/default/layer.css" rel="stylesheet" />
    <script src="../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Scripts/QueryString.js"></script>
    <script type="text/javascript" src="../Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="../Scripts/bootstrap/js/jquery.cokie.min.js"></script>
    <script type="text/javascript" src="../Scripts/QueryString.js"></script>
    <script type="text/javascript" src="../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="../Scripts/EasyUIUtility.js" type="text/javascript"></script>
    <script src="../Scripts/layui/layui/lay/modules/layer.js"></script>
    <script src="../../DataUser/JSLibData/CommonShowConfig.js"></script>
    <script src="../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../Scripts/QueryString.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Scripts/DealErrInfo.js"></script>

    <link href="../../DataUser/Style/ccbpm.css" rel="Stylesheet" />
    <!-- 导入配置文件. -->
    <script type="text/javascript" src="../Scripts/config.js"></script>
    <script src="../Comm/Gener.js" type="text/javascript"></script>
    <script type="text/javascript">
        var isFrameCross = GetQueryString("isFrameCross");
        if (isFrameCross == null || isFrameCross == undefined || isFrameCross == "" || isFrameCross == "null")
            isFrameCross = 0;
        var IsSend = GetQueryString("IsSend"); //是否发送？该参数是ToNodes.htm 带回来的.
        $(function () {
            //页面启动函数.
            if (IsSend == null || IsSend == undefined || IsSend == "")
                IsSend = "1";
            if (IsSend == "0")
                $("#Btn_Send").hide();
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
            var data = handler.DoMethodReturnString("AccepterOfOfficer_Init");
            if (data.indexOf("err@") != -1) {
                alert(data);
                console.log(data);
                return;
            }
            data = JSON.parse(data);
            BindTable(data);

        });
        function BindTable(sas) {
            for (var i = 0; i < sas.length; i++) {
                var sa = sas[i];
                var row = "";
                row += "<tr>";
                row += "<td><input type='checkbox'name='checkEmp' id='"+sa.No+"'/></td>";
                row += "<td>" + sa.Name + "</td>";
                row += "<td title='" + sa.DeptName + "' >" + sa.DeptName + "</td>";
                row += "</tr>";
                $("#Table1 tbody").append(row);
            }
        }
        //复选框全选反选
        function selectAll() {
            var obj = $("#selectAll");
            if (obj != null && obj != undefined && obj.prop("checked")) {
                $("input:checkbox").each(function () {
                    $(this).prop("checked", true);
                });
            } else {
                $("input:checkbox").each(function () {
                    $(this).prop("checked", false);
                });
            }
        };

        function Send() {

            //生成选择的人员.
            var checked = $('input:checked');
            var selectedEmps = [];
            for (var i = 0; i < checked.length; i++) {
                if (checked[i].id == "selectAll") {
                    continue;
                }
                selectedEmps.push(checked[i].id);
            }
            selectedEmps = selectedEmps.join(';');
            if (selectedEmps == '' || selectedEmps == null) {
                alert('请选择人员.');
                return;
            }


            $("#Msg").html("<font color=green><center>正在发送请稍候...</center></font>");

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
            handler.AddUrlData(); 

            handler.AddPara("SelectEmps", encodeURI(selectedEmps));
            var data = handler.DoMethodReturnString("Accepter_Send"); //执行发送方法.
            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }
            if (isFrameCross == 0) {
                if (window.parent != null && window.parent.WindowCloseReloadPage != null && typeof window.parent.WindowCloseReloadPage === "function") {
                    window.parent.WindowCloseReloadPage(data);
                } else {
                    if (typeof WindowCloseReloadPage != 'undefined' && WindowCloseReloadPage instanceof Function)
                        WindowCloseReloadPage(data);
                }
            } else {
                ChildrenPostMessage(data, "WindowCloseReloadPage");
            }


            data = data.replace("'MyFlowInfo", "'../MyFlowInfo");
            data = data.replace("'MyFlow.htm", "'../MyFlow.htm");
            data = data.replace("'MyFlow.htm", "'../MyFlow.htm");

            data = data.replace("'WFRpt", "'../WFRpt");
            data = data.replace("'WFRpt", "'../WFRpt");

            data = data.replace("'./Img", "'../Img");
            data = data.replace("'./Img", "'../Img");
            data = data.replace("'./Img", "'../Img");
            data = data.replace("'./Img", "'../Img");
            data = data.replace("'./Img", "'../Img");

            if (data.indexOf("UnSend.htm") == -1) {
                data = data.replace("'./WorkOpt/", "");
                data = data.replace("'./WorkOpt/", "");
                data = data.replace("'./WorkOpt/", "");
            }

            data = data.replace('@', '<br/>@');
            data = data.replace(/@/g, '<br/>&nbsp;@');
            data = data.replace('<br/><br/>&nbsp;', '');

            if (isFrameCross == 0) {
                if (window.parent != null && window.parent.returnWorkWindowClose != null) {
                    window.parent.returnWorkWindowClose(data);
                } else if (window.opener != undefined && window.opener.returnWorkWindowClose != undefined) {
                    window.opener.returnWorkWindowClose(data);
                } else {
                    $('body').append($('<div>' + data + '</div>'));
                    $('#btnSave').attr('disabled', true);
                }
            } else {
                ChildrenPostMessage(data, "returnWorkWindowClose");
            }
            $(".foot").hide();
        }

        //取消【选择接收人并发送】
        function CloseModel(flag, selectEmps) {
            if (selectEmps == null || selectEmps == undefined)
                selectEmps = "取消"
            if (isFrameCross == 0) {
                if (window.parent != null && window.parent.returnWorkWindowClose != null) {
                    window.parent.returnWorkWindowClose(selectEmps);
                    if (flag == true)
                        window.parent.close();
                    else
                        window.close();
                } else if (window.opener != undefined && window.opener.returnWorkWindowClose != undefined) {
                    window.opener.returnWorkWindowClose(selectEmps);
                    if (flag == true)
                        window.opener.close();
                    else
                        window.close();
                } else {
                    window.close();
                }
            } else {
                ChildrenPostMessage(selectEmps, "returnWorkWindowClose");
                if (flag == true)
                    window.parent.close();
                else
                    window.close();
            }

        }
    </script>
</head>
<body>
    <table class="table table-striped" id="Table1" style="width:98%;padding:5px; margin:10px;">
        <thead>
            <tr id="title" class="Sum">
                <td style="width:40px; font-weight:bolder"><input type="checkbox" id="selectAll" onclick="selectAll()" /></td>
                <td style="width:30%; font-weight:bolder">姓名</td>
                <td style="width:40%; font-weight:bolder">部门</td>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <div style="margin-left:20px">
        <div id="next">
            <button onclick="Send();" id="Btn_Send">
                <img src="../Img/Btn/Send.png" /> 发送
            </button>

            <button onclick="CloseModel();" id="Btn_Close">
                <img src="../Img/Btn/Close.png" /> 关闭
            </button>
        </div>

    </div>
</body>
</html>
